#include <iostream>
#include <vector>
#include <queue>
using namespace std;
const int N = 105;
int n;
int fa[N];
int dist[N];
vector<int> edges[N];
int dfs(int r)
{
	int ret = 0;
	for (auto v : edges[r])
	{
		ret = max(ret,dfs(v));
	}
	return ret+1;
}
int bfs(int r)
{
	queue<int> q;
	q.push(1);
	int ret = 0;
	while (q.size())
	{
		int sz = q.size();
		ret = max(ret, sz);
		while (sz--)
		{
			int u = q.front();q.pop();
			for (auto v : edges[u])
			{
				q.push(v);
			}
		}
	}
	return ret;
}
int main()
{
	cin >> n;
	int a, b;
	for(int i=1;i<n;i++)
	{
		cin >> a >> b;
		edges[a].push_back(b);
		fa[b] = a;
	}
	int x, y;
	cin >> x >> y;
	cout<<dfs(1)<<endl;
	cout << bfs(1)<<endl;
	while (x != 1)
	{
		dist[fa[x]] = dist[x] + 1;
		x = fa[x];
	}
	int len = 0;
	while (y != 1&&dist[y]==0)
	{
		y = fa[y];
		len++;
	}
	int dis = dist[y] * 2 + len;
	cout << dis;
	return 0;
}